Imports Wrox.Commerce

Partial Class ShopItem
    Inherits System.Web.UI.Page

    Sub btnAddToCart_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)

        Dim Price As Double = Double.Parse(CType(FormView1.FindControl("PriceLabel"), Label).Text)
        Dim ProductName As String = CType(FormView1.FindControl("NameLabel"), Label).Text
        Dim PictureURL As String = CType(FormView1.FindControl("PictureUrlLabel"), Label).Text
        Dim ProductID As Integer = CInt(Request.QueryString("ProductID"))

        ' create the cart if it doesn't already exist
        If Profile.Cart Is Nothing Then
            Profile.Cart = New Wrox.Commerce.ShoppingCart()
        End If

        ' insert the item
        ' if the item already exists in the cart, 1 will be added to the quantity

        Profile.Cart.Insert(ProductID, Price, 1, ProductName, PictureURL)

        ' return back to the main shop page
        Server.Transfer("Shop.aspx")
    End Sub

End Class
